package com.zany.children.dao;

import com.zany.children.vo.ChargesOwedDetail;
import com.zany.children.vo.PaymentProject;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import java.util.List;
import java.util.Map;

public class ChargesOwedDetailDaoImpl extends SqlMapClientDaoSupport implements ChargesOwedDetailDao {

    private SqlMapClientTemplate sqlMapClientTemplate = getSqlMapClientTemplate();

    @Override
    public Long saveChargesOwedDetail(ChargesOwedDetail chargesOwedDetail) {
        String key = "chargesoweddetail.saveChargesOwedDetail";
        Long id = (Long) sqlMapClientTemplate.insert(key, chargesOwedDetail);
        return id;
    }

    @Override
    public void updateChargesOwedDetail(ChargesOwedDetail chargesOwedDetail) {
        String key = "chargesoweddetail.updateChargesOwedDetail";
        int update = sqlMapClientTemplate.update(key, chargesOwedDetail);
    }


    @Override
    public void deleteChargesOwedDetailById(Long id) {
        String key = "chargesoweddetail.deleteChargesOwedDetailById";
        sqlMapClientTemplate.update(key, id);
    }

    @Override
    public List<ChargesOwedDetail> getChargesOwedDetailListPage(ChargesOwedDetail chargesOwedDetail) {
        String key = "chargesoweddetail.getChargesOwedDetailListPage";
        return sqlMapClientTemplate.queryForList(key, chargesOwedDetail);
    }

    @Override
    public Integer getChargesOwedDetailListPageCount(ChargesOwedDetail chargesOwedDetail) {
        String key = "chargesoweddetail.getChargesOwedDetailListPageCount";
        Integer count = (Integer) sqlMapClientTemplate.queryForObject(key, chargesOwedDetail);
        return count;
    }

    @Override
    public ChargesOwedDetail getChargesOwedDetailById(Long id) {
        String key = "chargesoweddetail.getChargesOwedDetailById";
        return (ChargesOwedDetail)sqlMapClientTemplate.queryForObject(key, id);
    }

    @Override
    public List<ChargesOwedDetail> getChargesOwedDetailByCondition(Map<String, Object> map) {
        String key = "chargesoweddetail.getChargesOwedDetailByCondition";
        return sqlMapClientTemplate.queryForList(key, map);
    }


    @Override
    public List<PaymentProject> getProjectListByStuId(Map<String,Object> map) {
        String key = "chargesoweddetail.getProjectListByStuId";
        return sqlMapClientTemplate.queryForList(key, map);
    }
}
